<?php

/**
 * vip管理
 * Created by PhpStorm.
 * User: deng
 * Date: 2016/12/22
 * Time: 15:00
 */
class PinkVip extends AdminBase{

    protected $do;

    function __construct(){
        parent::__construct();
        $this->do = 'vipManage';
        $this->{$this->op}();
    }

    function indexAction(){
        include_once template("admin_v2/vip");
        exit();
    }

    function listAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'list',
        ], $this->req));
    }

    function detailAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'detail',
            'id' => $this->req['id']
        ]);
    }

    function editdetailAction(){
        $this->req['start_time'] = $this->req['start_time'] ? strtotime($this->req['start_time']) : time();
        $this->req['end_time'] = $this->req['end_time'] ? strtotime($this->req['end_time']) : time()+(24*3600);
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'edit',
        ], $this->req));
    }

    function addAction(){
        $this->req['start_time'] = $this->req['start_time'] ? strtotime($this->req['start_time']) : time();
        $this->req['end_time'] = $this->req['end_time'] ? strtotime($this->req['end_time']) : time()+(24*3600);
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'add',
        ], $this->req));
    }

    function findAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'find',
            'uid' => $this->req['uid']
        ]);
    }

    function deleteAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'delete',
            'id' => $this->req['id']
        ]);
    }

    function deviceAction(){
        include_once template("admin_v2/device");
        exit();
    }

    function dvlistAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'deviceList',
        ], $this->req));
    }

    function dveditAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'deviceEdit',
        ], $this->req));
    }

    function dvdeleteAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'deviceDel',
            'id' => $this->req['id']
        ]);
    }

    function dvaddAction(){
        foreach ($this->req as &$item){
            $item = urlencode($item);
        }
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'deviceAdd',
        ], $this->req));
    }

}

new PinkVip;




/*

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=vip';
$_SC['apiurl'] = "http://local.ffrj.net/adminApi.php";

$list = array();
if ($_GET ['op'] == "chain") {
    // 封禁&解禁
} else {
    // 构建api请求url与参数数组
//     $param = array(
//         'do' => 'getAllRecords',
//         'format' => 'json',
//     );

	$param = array(
	        'do' => 'openVip',
	        'format' => 'json',
			'status'=>	1,	
			'order'	=>	'ffvip_3899627_1387853560',
			'aUid'	=>	'3894301',
	    );
	
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->resultData) {
        $list = object_to_array($content->resultData);
    }
    // page
    $pageurl = multi($start, $perpage, $mpurl);
    $perpages = array(
        $perpage => ' selected'
    );
}
*/



